package com.ra.jalmanac;

import com.ra.jalmanac.hibernate.dao.Book;
import com.ra.jalmanac.hibernate.dao.BookDao;

import com.ra.jalmanac.logger.Logger;
import java.util.Calendar;

import org.apache.commons.logging.Log;
import org.springframework.context.ApplicationContext;



public class Runner implements IRunner {

    @Logger private Log log;

    @Override
    public void run() {
        log.info("Running");
        
        Book b = new Book();
        b.setIsbn("1234");
        b.setName("Hibernate Recepies");
        b.setPrice(30);
        b.setPublishDate(Calendar.getInstance().getTime());
        
        ApplicationContext ctx =  AppContextProvider.getApplicationContext();
        
        BookDao dao = (BookDao)ctx.getBean("bookDao");
        try {
            dao.save(b);
        } catch (Exception ex) {
            log.debug(ex);
        }
        
    }

}
